linux: simplify and perform checking of multicall status
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 5 Apr 2007 09:43:50 +0000 (10:43 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 5 Apr 2007 09:43:50 +0000 (10:43 +0100)
Signed-off-by: Jan Beulich <jbeulich@novell.com>
linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h
linux-2.6-xen-sparse/include/xen/hvm.h
linux-2.6-xen-sparse/include/xen/hypercall.h [new file with mode: 0644]

index f7c806e351be80391ff0e55717730c922ad5ec43..d1d65cf4b87397156fcae8c2fb041fca2a733ed2 100644 (file)
@@ -303,7 +303,7 @@ int xen_create_contiguous_region(
                set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
                        INVALID_P2M_ENTRY);
        }
-       if (HYPERVISOR_multicall(cr_mcl, i))
+       if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
                BUG();
 
        /* 2. Get a new contiguous memory extent. */
@@ -342,7 +342,7 @@ int xen_create_contiguous_region(
        cr_mcl[i - 1].args[MULTI_UVMFLAGS_INDEX] = order
                                                   ? UVMF_TLB_FLUSH|UVMF_ALL
                                                   : UVMF_INVLPG|UVMF_ALL;
-       if (HYPERVISOR_multicall(cr_mcl, i))
+       if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
                BUG();
 
        if (success)
@@ -400,7 +400,7 @@ void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
                        INVALID_P2M_ENTRY);
                out_frames[i] = (__pa(vstart) >> PAGE_SHIFT) + i;
        }
-       if (HYPERVISOR_multicall(cr_mcl, i))
+       if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
                BUG();
 
        /* 3. Do the exchange for non-contiguous MFNs. */
@@ -432,7 +432,7 @@ void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
        cr_mcl[i - 1].args[MULTI_UVMFLAGS_INDEX] = order
                                                   ? UVMF_TLB_FLUSH|UVMF_ALL
                                                   : UVMF_INVLPG|UVMF_ALL;
-       if (HYPERVISOR_multicall(cr_mcl, i))
+       if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
                BUG();
 
        balloon_unlock(flags);
index 41b1405ff77867fbe14a398d0ac4bbfc41a9f305..bdf7dda07e633c2ad5b850fbef60dbb2244225fb 100644 (file)
@@ -7,7 +7,6 @@
 #include <xen/interface/kexec.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
-#include <asm/hypercall.h>
 
 extern void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, 
                                         struct kimage *image);
index 17d1daf6586130cf1971e436ea488a82eeeaf7e3..d2abc56fd48d89aee6c72f002f7cc4f4e2310ef1 100644 (file)
@@ -1511,7 +1511,7 @@ static void netif_release_rx_bufs(struct netfront_info *np)
        struct sk_buff *skb;
        unsigned long mfn;
        int xfer = 0, noxfer = 0, unused = 0;
-       int id, ref;
+       int id, ref, rc;
 
        if (np->copying_receiver) {
                WPRINTK("%s: fix me for copying receiver.\n", __FUNCTION__);
@@ -1579,7 +1579,9 @@ static void netif_release_rx_bufs(struct netfront_info *np)
                        mcl->args[2] = 0;
                        mcl->args[3] = DOMID_SELF;
                        mcl++;
-                       HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
+                       rc = HYPERVISOR_multicall_check(
+                               np->rx_mcl, mcl - np->rx_mcl, NULL);
+                       BUG_ON(rc);
                }
        }
 
index 44b3b7401aed19d9fdd30eeace674c0279f9099e..2526d206a123313f1408acd1882fcfe07b41ff8c 100644 (file)
@@ -238,7 +238,7 @@ HYPERVISOR_memory_op(
 
 static inline int
 HYPERVISOR_multicall(
-       void *call_list, int nr_calls)
+       multicall_entry_t *call_list, int nr_calls)
 {
        return _hypercall2(int, multicall, call_list, nr_calls);
 }
index b7c7a05cf510707646665fe55fb2b7bc5f89a9ac..e65d81a8a379ec0b5d4c4119b321aa95f57328b4 100644 (file)
@@ -128,7 +128,7 @@ u64 jiffies_to_st(unsigned long jiffies);
 #define scrub_pages(_p,_n) ((void)0)
 #endif
 
-#include <asm/hypercall.h>
+#include <xen/hypercall.h>
 
 #if defined(CONFIG_X86_64)
 #define MULTI_UVMFLAGS_INDEX 2
index 712778213d71183902cc71ee98cfee91f9c806e9..e7f345b46579dce860c4708e84449e9d38ae53e2 100644 (file)
@@ -55,7 +55,7 @@ extern int running_on_xen;
 #include <xen/interface/event_channel.h>
 #include <xen/interface/physdev.h>
 #include <xen/interface/sched.h>
-#include <asm/hypercall.h>
+#include <xen/hypercall.h>
 #include <asm/ptrace.h>
 #include <asm/page.h>
 
index 4eb21a925109541fb10f9958f8604d2ab219b4ef..0f4aa7f0f2adf660d8a99080af505c18f4e5629e 100644 (file)
@@ -241,7 +241,7 @@ HYPERVISOR_memory_op(
 
 static inline int
 HYPERVISOR_multicall(
-       void *call_list, int nr_calls)
+       multicall_entry_t *call_list, int nr_calls)
 {
        return _hypercall2(int, multicall, call_list, nr_calls);
 }
index 97bb68a32920be0eab6b6139252309048b7bcd36..4ea8887dc3ec731637f3aca55c31445e5f947f75 100644 (file)
@@ -3,7 +3,6 @@
 #define XEN_HVM_H__
 
 #include <xen/interface/hvm/params.h>
-#include <asm/hypercall.h>
 
 static inline unsigned long hvm_get_parameter(int idx)
 {
diff --git a/linux-2.6-xen-sparse/include/xen/hypercall.h b/linux-2.6-xen-sparse/include/xen/hypercall.h
new file mode 100644 (file)
index 0000000..decb883
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __XEN_HYPERCALL_H__
+#define __XEN_HYPERCALL_H__
+
+#include <asm/hypercall.h>
+
+static inline int
+HYPERVISOR_multicall_check(
+       multicall_entry_t *call_list, int nr_calls,
+       const unsigned long *rc_list)
+{
+       int rc = HYPERVISOR_multicall(call_list, nr_calls);
+
+       if (unlikely(rc < 0))
+               return rc;
+       BUG_ON(rc);
+
+       for ( ; nr_calls > 0; --nr_calls, ++call_list)
+               if (unlikely(call_list->result != (rc_list ? *rc_list++ : 0)))
+                       return nr_calls;
+
+       return 0;
+}
+
+#endif /* __XEN_HYPERCALL_H__ */